var EdlParser = function() {			
};
EdlParser.prototype = {
	/**
	 * Creates an array containing a {id, source_in, source_out, record_in, record_out, clip_name} object for each subtitle line. 
	 */
	parse: function(string) {
		var result = [];  
		var line_strings = string.split('\n'); 
		var o = {}; 
		$(line_strings).each(function(i,line) { 
			if (i>2) {
				var parts = line.replace(/ +(?= )/g,'').split(' ');			
				var is_first_line = !(isNaN(line.charAt(0))) && line.charAt(0) != ''; 
				var is_second_line = line.indexOf('* FROM CLIP NAME:') != -1;
				var is_last_line = line.substr(0,2) == 'M2';
				if ( is_first_line ) {
					o = {
						id: parts[0],
						source_in: parts[4],
						source_out: parts[5],
						record_in: parts[6],
						record_out: parts[7]
					}
				}
				if (is_second_line) {
					o.clip_name = line.split('* FROM CLIP NAME: ')[1];
				}
				if (is_last_line) {
					result.push(o);
				}
			}
		}); 
		return result;
	},
	
	getTitle: function(string){
		return string.split('\n')[0].split('TITLE: ')[1];
	}
}